# -*- coding:utf-8 -*-
'''
@File    :   login_demo_api.py
@Time    :   2024/11/17 10:55:32
@Author  :   xiangyu Chen
@Version :   1.0
@Contact :   yu112yu@sina.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA
@Desc    :   None
'''

import requests
from utils.request_utils import RequestHandler
from pprint import pprint

# requests.Session


# 实现登录接口 ，暂时不考虑封装
def login(username, password, token):
    login_path = 'http://localhost:8080/admin/auth/loginpytest'
    login_data = {"username": username, "password": password, 'token': token}
    # response = requests.post(login_path, json=login_data)  # 实现登录

    response = requests.request("POST", login_path, json=login_data)
    # result = response.json()  # 返回的请求体数据以json显示
    return response


def login_RequestHandler(username, password, token):
    login_path = 'http://localhost:8080/admin/auth/loginpytest'
    login_data = {"username": username, "password": password, 'token': token}
    headers = []
    req = RequestHandler()
    response = req.httpcore("POST", url=login_path, headers=headers, json=login_data)
    # response = requests.request("POST", login_path, json=login_data)
    # result = response.json()  # 返回的请求体数据以json显示
    return response


if __name__ == '__main__':
    # print(login('1', '2', '3').json())
    pprint(login_RequestHandler('1', '2', '3').json())
